package com.feib.soeasy.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;


/**
 * @title (#)UploadFile.java<br>
 * @description 使用者上傳紀錄<br>
 * @author Jimmy Liu<br>
 * @version 1.0.0 2010/11/25
 * @copyright Far Eastern International Bank Copyright (c) 2010<br>
 * @2010/11/7 create by Jimmy Liu<br>
 */
@Entity
@Table(name = "UPLOAD_FILE")
public class UploadFile extends AuditEntity {

    private static final long serialVersionUID = 5413699855854341858L;
    
    /**
     * 檔案狀態代碼類別
     */
    public static final String FILE_STATUS_CODE_KIND = "UPLOAD_FILE_STATUS";

    /**
     * 檔案狀態:已上傳待檢查 
     */
    public static final Integer FILE_STATUS_UN_CHECK = new Integer(0);
    
    /**
     * 檔案狀態:檢查中 
     */
    public static final Integer FILE_STATUS_IN_CHECKING = new Integer(1);
    
    /**
     * 檔案狀態:檔案檢核未通過 
     */
    public static final Integer FILE_STATUS_CHECK_ERROR = new Integer(2);
    
    /**
     * 檔案狀態:待放行(檔案檢核通過)
     */
    public static final Integer FILE_STATUS_WAITING_CONFIRM = new Integer(3);
    
    /**
     * 檔案狀態:確認放行
     */
    public static final Integer FILE_STATUS_CONFIRM_OK = new Integer(4);
    
    /**
     * 檔案狀態:不放行(表上傳資料有誤) 
     */
    public static final Integer FILE_STATUS_CONFIRM_NOT_OK = new Integer(5);
    /**
     * 檔案狀態:繳費單產生中
     */
    public static final Integer FILE_STATUS_CREATE_REPORT = new Integer(9);

    /**
     * PK in Table
     */
    private Long uploadFilePk;

    /**
     * 檔案格式
     */
    private FormatDefinition formatDefinition;

    /**
     * 上傳人員
     */
    private User uploadUser;

    /**
     * 所屬群組</br>
     * 因為銀行可替帳單業者上傳檔案，所以需要此欄位確定是屬於哪一個帳單業者</br>
     * 不要使用上傳人員來判斷此檔案是屬於哪一個帳單業者</br>
     */
    private Group group;

    /**
     * 上傳原始檔名
     */
    private String fileName;

    /**
     * 上傳至Server後的檔名(完整路徑)
     */
    private String filePathOnServer;

    /**
     * 總金額
     */
    private Long totalAmount;

    /**
     * 總筆數
     */
    private Long totalItems;

    /**
     * 檔案狀態<br>
     * 0: 已上傳待檢查 
     * 1: 檢查中 
     * 2: 檢核未通過 
     * 3: 待放行
     * 4: 確認放行
     * 5: 不放行(表上傳資料有誤) 
     * 9: 繳費單產生中
     */
    private Integer fileStatus;

    /**
     * 上傳日期
     */
    private Date uploadDate;

    /**
     * 確認放行日期
     */
    private Date confirmDate;

    /**
     * 確認放行人員</br>
     * 放行人員與上傳人員要同一個帳單業者</br>
     * confirmUser.group.groupPk =uploadUser.group.groupPk
     */
    private User confirmUser;

    /**
     * 放行狀態<br>
     * True: 放行
     * False: 不放行
     * Null: 未確認
     */
    private Boolean confirmStatus;
    
    /**
     * 合併帳單檔名(供下載用)
     */
    private String pdfFileName;
    
    /**
     * 合併帳單於Server的檔名(完整路徑)
     */
    private String pdfFilePathOnServer;


    /**
     * @return the uploadFilePk
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name="UPLOAD_FILE_PK", nullable=false)
    public Long getUploadFilePk() {
        return uploadFilePk;
    }


    /**
     * @param uploadFilePk the uploadFilePk to set
     */
    public void setUploadFilePk(Long uploadFilePk) {
        this.uploadFilePk = uploadFilePk;
    }



    /**
     * @return the formatDefinition
     */
    @ManyToOne
    @JoinColumn(name="FORMAT_DEF_PK", nullable=false)
    public FormatDefinition getFormatDefinition() {
        return formatDefinition;
    }



    /**
     * @param formatDefinition the formatDefinition to set
     */
    public void setFormatDefinition(FormatDefinition formatDefinition) {
        this.formatDefinition = formatDefinition;
    }


    /**
     * @return the uploadUser
     */
    @ManyToOne
    @JoinColumn(name="UPLOAD_USER_PK", nullable=false)
    public User getUploadUser() {
        return uploadUser;
    }


    /**
     * @param uploadUser the uploadUser to set
     */
    public void setUploadUser(User uploadUser) {
        this.uploadUser = uploadUser;
    }


    /**
     * @return the group
     */
    @ManyToOne
    @JoinColumn(name="GROUP_PK", nullable=false)
    public Group getGroup() {
        return group;
    }


    /**
     * @param group the group to set
     */
    public void setGroup(Group group) {
        this.group = group;
    }


    /**
     * @return the fileName
     */
    @Column(name="FILE_NAME", nullable=false, length=100)
    public String getFileName() {
        return fileName;
    }


    /**
     * @param fileName the fileName to set
     */
    public void setFileName(String fileName) {
        this.fileName = fileName;
    }


    /**
     * @return the filePathOnServer
     */
    @Column(name="FILE_PATH_ON_SERVER", nullable=false, length=255)
    public String getFilePathOnServer() {
        return filePathOnServer;
    }


    /**
     * @param filePathOnServer the filePathOnServer to set
     */
    public void setFilePathOnServer(String filePathOnServer) {
        this.filePathOnServer = filePathOnServer;
    }



    /**
     * @return the totalAmount
     */
    @Column(name="TOTAL_AMOUNT")
    public Long getTotalAmount() {
        return totalAmount;
    }



    /**
     * @param totalAmount the totalAmount to set
     */
    public void setTotalAmount(Long totalAmount) {
        this.totalAmount = totalAmount;
    }



    /**
     * @return the totalItems
     */
    @Column(name="TOTAL_ITEMS")
    public Long getTotalItems() {
        return totalItems;
    }



    /**
     * @param totalItems the totalItems to set
     */
    public void setTotalItems(Long totalItems) {
        this.totalItems = totalItems;
    }


    /**
     * @return the fileStatus
     */
    @Column(name="FILE_STATUS", nullable=false)
    public Integer getFileStatus() {
        return fileStatus;
    }


    /**
     * @param fileStatus the fileStatus to set
     */
    public void setFileStatus(Integer fileStatus) {
        this.fileStatus = fileStatus;
    }


    /**
     * @return the uploadDate
     */
    @Column(name="UPLOAD_DATE", nullable=false)
    public Date getUploadDate() {
        return uploadDate;
    }


    /**
     * @param uploadDate the uploadDate to set
     */
    public void setUploadDate(Date uploadDate) {
        this.uploadDate = uploadDate;
    }


    /**
     * @return the confirmDate
     */
    @Column(name="CONFIRM_DATE")
    public Date getConfirmDate() {
        return confirmDate;
    }


    /**
     * @param confirmDate the confirmDate to set
     */
    public void setConfirmDate(Date confirmDate) {
        this.confirmDate = confirmDate;
    }


    /**
     * @return the confirmUser
     */
    @ManyToOne
    @JoinColumn(name="CONFIRM_USER_PK")
    public User getConfirmUser() {
        return confirmUser;
    }


    /**
     * @param confirmUser the confirmUser to set
     */
    public void setConfirmUser(User confirmUser) {
        this.confirmUser = confirmUser;
    }


    /**
     * @return the confirmStatus
     */
    @Column(name="CONFIRM_STATUS")
    public Boolean getConfirmStatus() {
        return confirmStatus;
    }


    /**
     * @param confirmStatus the confirmStatus to set
     */
    public void setConfirmStatus(Boolean confirmStatus) {
        this.confirmStatus = confirmStatus;
    }

    
    /**
     * @return the pdfFileName
     */
    @Column(name="PDF_FILE_NAME", nullable=true, length=100)
    public String getPdfFileName() {
        return pdfFileName;
    }


    
    /**
     * @param pdfFileName the pdfFileName to set
     */
    public void setPdfFileName(String pdfFileName) {
        this.pdfFileName = pdfFileName;
    }


    
    /**
     * @return the pdfFilePathOnServer
     */
    @Column(name="PDF_FILE_PATH_ON_SERVER", nullable=true, length=255)
    public String getPdfFilePathOnServer() {
        return pdfFilePathOnServer;
    }


    
    /**
     * @param pdfFilePathOnServer the pdfFilePathOnServer to set
     */
    public void setPdfFilePathOnServer(String pdfFilePathOnServer) {
        this.pdfFilePathOnServer = pdfFilePathOnServer;
    }
}
